package br.ufpe.cin.bf.persistence;

import java.util.Map;

import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.resource.ResourceSet;
import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
import org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl;

import br.ufpe.cin.bf.BenchmarkingFramework;
import br.ufpe.cin.bf.BfPackage;

public class ModelLoad {
	
	public static BenchmarkingFramework load(String fileLocation){
		
		BfPackage.eINSTANCE.eClass();
		
		Resource.Factory.Registry reg = Resource.Factory.Registry.INSTANCE;
		Map<String, Object> m = reg.getExtensionToFactoryMap();
		m.put("bf", new XMIResourceFactoryImpl());
		
		ResourceSet resSet = new ResourceSetImpl();
		
		Resource resource = resSet.getResource(URI.createURI(fileLocation), true);
		
		BenchmarkingFramework bf = (BenchmarkingFramework) resource.getContents().get(0);
		
		return bf;
	}

}
